package com.ntv.presentation.spring.web.flashnews;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.ntv.domain.INews;
import com.ntv.service.flashnews.IFlashNewsAppService;


@Controller
@RequestMapping("/flashnewshome.html")
public class FlashNewsHomeController {
	
	private static final Logger logger = Logger.getLogger(FlashNewsHomeController.class);
	@Autowired
	private IFlashNewsAppService flashNewsAppService;

	/**
	 * @param flashNewsAppService
	 *            the flashNewsAppService to set
	 */
	public void setFlashNewsAppService(IFlashNewsAppService flashNewsAppService) {
		this.flashNewsAppService = flashNewsAppService;
	}

	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView form(Model modelll) throws Exception {
		List<INews> flashNewsList = flashNewsAppService
				.getCurrentDayFlashNews();
		Map model = new HashMap();
		model.put("FlashNewsList", flashNewsList);
		logger.info("Size " + flashNewsList.size());
		ModelAndView mav = new ModelAndView("home.flashnews", model);
		return mav;
	}

}
